package com.ThreadStudy.syn;
/*
*
* 不安全的买票
*
*
* */
public class UnSafeBuyTicket {

    public static void main(String[] args) {

        BuyTicket buyTicket1 = new BuyTicket();

        Thread thread1 = new Thread(buyTicket1,"小张");
        Thread thread2 = new Thread(buyTicket1,"小王");

        thread1.start();
        thread2.start();

    }

}



class BuyTicket implements Runnable{
    // 票:
    private int ticket = 100;

    @Override
    public void run() {
        while (ticket>0){
            System.out.println(Thread.currentThread().getName()+"买到第->"+(ticket--)+"张票");
        }

    }
}
